<template>
  <div id="docx-demo">
    <el-upload
      :limit="1"
      :file-list="fileList"
      accept=".docx"
      :beforeUpload="beforeUpload"
      action=""
    >
      <el-button size="small" type="warning">点击上传</el-button>
    </el-upload>
    <vue-office-docx :src="src" />
  </div>
</template>
<script setup>
import VueOfficeDocx from "@vue-office/docx";
import "@vue-office/docx/lib/index.css";

const src = ref("");
const fileList = ref([]);
const beforeUpload = (file) => {
  let reader = new FileReader();
  reader.readAsArrayBuffer(file);
  reader.onload = (loadEvent) => {
    src.value = loadEvent.target.result;
  };
  return false;
};
</script>
<style scoped lang="scss"></style>
